﻿using System;
using NUnit.Framework;

namespace WebCrawler.Tests
{
    [TestFixture]
    public class CommandLineProcessorTests
    {
        //[Test]
        //[ExpectedException(typeof(ArgumentNullException), ExpectedMessage = "argName", MatchType = MessageMatch.Contains)]
        //public void CheckNotNull_ShouldFailOnNull()
        //{
        //    object nullObj = null;
        //    nullObj.CheckNotNull("argName");
        //}
        [Test]
        public void Should_ValidateCommandLine_And_ParseStartUrl()
        {
            var processor = new CommandLineProcessor();
            var emptyArgs = new string[] {};
            var res = processor.TryParse(emptyArgs);
            Assert.IsFalse(res, "empty command line");

            string url = "http://www.company.com";
            string invalidUrl = "http://";
            
            var correctArgs = new[] {url};
            res = processor.TryParse(correctArgs);
            Assert.IsTrue(res, "valid url");
            Assert.That(processor.StartUrl, Is.EqualTo(url));

            res = processor.TryParse(new string[]{invalidUrl});
            Assert.IsFalse(res, "invalid url");

            var manyArgs = new[] { url, "http://company.com" };
            res = processor.TryParse(manyArgs);
            Assert.IsFalse(res);
        }
    }
}
